#include <iostream>
#include <string>
using namespace std;

class Building;

//当一个类的成员函数做另一个类的友元函数时，这个类需要在另一个类前提前完成 完整定义
class Good_Friend {
public:
    Good_Friend();
    void visit(); //让其可以访问Building类中私有成员变量
    void visit2(); // 让其不可以访问Building类中私有成员变量

private:
    Building * building;
};

class Building {
    friend void Good_Friend::visit();
public:
    string m_setting_room;
    Building();

private:
    string m_bed_room;
};

//在类外声明
Building :: Building() {
    m_setting_room = "客厅";
    m_bed_room = "卧室";
}
Good_Friend :: Good_Friend() {
    building = new Building();
}
void Good_Friend::visit() {
    cout << "朋友可以参观：" << building -> m_setting_room << endl;
    cout << "朋友可以参观：" << building -> m_bed_room << endl;
}
void Good_Friend::visit2() {
    cout << "朋友不可以参观：" << building -> m_setting_room << endl;
    //cout << "朋友可以参观：" << building -> m_bed_room << endl;  不是 Building类的友元函数 不能调用该类的私有成员
}

void test() {
    Good_Friend good_friend;
    good_friend.visit();
    good_friend.visit2();
}

int main() {
    test();
    return 0;
}